<?php

class AgentIsLookBehavior extends CActiveRecordBehavior {

	public function beforeFind($event) {
		$userAdmin = Yii::app()->adminUser;
		$owner = $this->owner;
		
		if ($userAdmin->role == AdminUser::ROLE_OPERATOR) {
			return true;
		} else if ($userAdmin->role == AdminUser::ROLE_DEALER) {
			$related = AgentRelated::model()->related($userAdmin->id, CHtml::value($owner, 'goods.provider_id'));
			if (CHtml::value($related, 'status') == 'ST_PASSED')
				return true;
		}
		
		$owner->price_agent = '****';
	}
}

?>